def number(n):
    count = 0
    m=str(number(n))
    for i in m:
        if i == 0 or i == 6 or i == 9:
            count += 1
        elif i == 8:
            count += 2
    return count


n = int(input())
print(number(n))
